#!/bin/bash

logRotateConf=/etc/logrotate.d/lognplay
appName=$1
fileName="/var/log/lognplay/$appName.log.1"
host="http://ec2-177-71-224-71.sa-east-1.compute.amazonaws.com:9200"

# run logrotate for lognplay
logrotate -f $logRotateConf

# index file
cat $fileName | while read line
do
	curl -XPOST "http://$host/$appName/logmsg" -d "$line"
done

rm /var/log/lognplay/*.1
